﻿#region Using directives

using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using NiSis.Entities;
using NiSis.Data;

#endregion

namespace NiSis.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="VBatchTraderPrecStProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract class VBatchTraderPrecStProviderBaseCore : EntityViewProviderBase<VBatchTraderPrecSt>
	{
		#region Custom Methods
		
		
		#region UpdateUtenzeState
		
		/// <summary>
		///	This method wrap the 'UpdateUtenzeState' stored procedure. 
		/// </summary>
		/// <param name="idTraderPrecedente"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newIdStato"> A <c>System.Int32?</c> instance.</param>
		/// <param name="nota"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void UpdateUtenzeState(System.Int32? idTraderPrecedente, System.Int32? newIdStato, System.String nota)
		{
			 UpdateUtenzeState(null, 0, int.MaxValue , idTraderPrecedente, newIdStato, nota);
		}
		
		/// <summary>
		///	This method wrap the 'UpdateUtenzeState' stored procedure. 
		/// </summary>
		/// <param name="idTraderPrecedente"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newIdStato"> A <c>System.Int32?</c> instance.</param>
		/// <param name="nota"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void UpdateUtenzeState(int start, int pageLength, System.Int32? idTraderPrecedente, System.Int32? newIdStato, System.String nota)
		{
			 UpdateUtenzeState(null, start, pageLength , idTraderPrecedente, newIdStato, nota);
		}
				
		/// <summary>
		///	This method wrap the 'UpdateUtenzeState' stored procedure. 
		/// </summary>
		/// <param name="idTraderPrecedente"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newIdStato"> A <c>System.Int32?</c> instance.</param>
		/// <param name="nota"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void UpdateUtenzeState(TransactionManager transactionManager, System.Int32? idTraderPrecedente, System.Int32? newIdStato, System.String nota)
		{
			 UpdateUtenzeState(transactionManager, 0, int.MaxValue , idTraderPrecedente, newIdStato, nota);
		}
		
		/// <summary>
		///	This method wrap the 'UpdateUtenzeState' stored procedure. 
		/// </summary>
		/// <param name="idTraderPrecedente"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newIdStato"> A <c>System.Int32?</c> instance.</param>
		/// <param name="nota"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void UpdateUtenzeState(TransactionManager transactionManager, int start, int pageLength, System.Int32? idTraderPrecedente, System.Int32? newIdStato, System.String nota);
		
		#endregion

		
		#region UtenzeGasStoricoUpdateAll
		
		/// <summary>
		///	This method wrap the 'UtenzeGasStoricoUpdateAll' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idState"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void UtenzeGasStoricoUpdateAll(System.Int32? idBatch, System.Int32? idState)
		{
			 UtenzeGasStoricoUpdateAll(null, 0, int.MaxValue , idBatch, idState);
		}
		
		/// <summary>
		///	This method wrap the 'UtenzeGasStoricoUpdateAll' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idState"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void UtenzeGasStoricoUpdateAll(int start, int pageLength, System.Int32? idBatch, System.Int32? idState)
		{
			 UtenzeGasStoricoUpdateAll(null, start, pageLength , idBatch, idState);
		}
				
		/// <summary>
		///	This method wrap the 'UtenzeGasStoricoUpdateAll' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idState"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void UtenzeGasStoricoUpdateAll(TransactionManager transactionManager, System.Int32? idBatch, System.Int32? idState)
		{
			 UtenzeGasStoricoUpdateAll(transactionManager, 0, int.MaxValue , idBatch, idState);
		}
		
		/// <summary>
		///	This method wrap the 'UtenzeGasStoricoUpdateAll' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="idState"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void UtenzeGasStoricoUpdateAll(TransactionManager transactionManager, int start, int pageLength, System.Int32? idBatch, System.Int32? idState);
		
		#endregion

		
		#region CleanUpHistory
		
		/// <summary>
		///	This method wrap the 'CleanUpHistory' stored procedure. 
		/// </summary>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void CleanUpHistory(System.String cdMese)
		{
			 CleanUpHistory(null, 0, int.MaxValue , cdMese);
		}
		
		/// <summary>
		///	This method wrap the 'CleanUpHistory' stored procedure. 
		/// </summary>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void CleanUpHistory(int start, int pageLength, System.String cdMese)
		{
			 CleanUpHistory(null, start, pageLength , cdMese);
		}
				
		/// <summary>
		///	This method wrap the 'CleanUpHistory' stored procedure. 
		/// </summary>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void CleanUpHistory(TransactionManager transactionManager, System.String cdMese)
		{
			 CleanUpHistory(transactionManager, 0, int.MaxValue , cdMese);
		}
		
		/// <summary>
		///	This method wrap the 'CleanUpHistory' stored procedure. 
		/// </summary>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void CleanUpHistory(TransactionManager transactionManager, int start, int pageLength, System.String cdMese);
		
		#endregion

		
		#region GetUtenze
		
		/// <summary>
		///	This method wrap the 'GetUtenze' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetUtenze(System.String cdPool, System.String cdMese, System.String cdTraderPrec)
		{
			return GetUtenze(null, 0, int.MaxValue , cdPool, cdMese, cdTraderPrec);
		}
		
		/// <summary>
		///	This method wrap the 'GetUtenze' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetUtenze(int start, int pageLength, System.String cdPool, System.String cdMese, System.String cdTraderPrec)
		{
			return GetUtenze(null, start, pageLength , cdPool, cdMese, cdTraderPrec);
		}
				
		/// <summary>
		///	This method wrap the 'GetUtenze' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetUtenze(TransactionManager transactionManager, System.String cdPool, System.String cdMese, System.String cdTraderPrec)
		{
			return GetUtenze(transactionManager, 0, int.MaxValue , cdPool, cdMese, cdTraderPrec);
		}
		
		/// <summary>
		///	This method wrap the 'GetUtenze' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetUtenze(TransactionManager transactionManager, int start, int pageLength, System.String cdPool, System.String cdMese, System.String cdTraderPrec);
		
		#endregion

		
		#region ConsolidateUsr
		
		/// <summary>
		///	This method wrap the 'ConsolidateUsr' stored procedure. 
		/// </summary>
		/// <param name="cdMeseAnno"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void ConsolidateUsr(System.String cdMeseAnno)
		{
			 ConsolidateUsr(null, 0, int.MaxValue , cdMeseAnno);
		}
		
		/// <summary>
		///	This method wrap the 'ConsolidateUsr' stored procedure. 
		/// </summary>
		/// <param name="cdMeseAnno"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void ConsolidateUsr(int start, int pageLength, System.String cdMeseAnno)
		{
			 ConsolidateUsr(null, start, pageLength , cdMeseAnno);
		}
				
		/// <summary>
		///	This method wrap the 'ConsolidateUsr' stored procedure. 
		/// </summary>
		/// <param name="cdMeseAnno"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void ConsolidateUsr(TransactionManager transactionManager, System.String cdMeseAnno)
		{
			 ConsolidateUsr(transactionManager, 0, int.MaxValue , cdMeseAnno);
		}
		
		/// <summary>
		///	This method wrap the 'ConsolidateUsr' stored procedure. 
		/// </summary>
		/// <param name="cdMeseAnno"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void ConsolidateUsr(TransactionManager transactionManager, int start, int pageLength, System.String cdMeseAnno);
		
		#endregion

		
		#region ChangeBatchState
		
		/// <summary>
		///	This method wrap the 'ChangeBatchState' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newState"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void ChangeBatchState(System.Int32? idBatch, System.Int32? newState)
		{
			 ChangeBatchState(null, 0, int.MaxValue , idBatch, newState);
		}
		
		/// <summary>
		///	This method wrap the 'ChangeBatchState' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newState"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void ChangeBatchState(int start, int pageLength, System.Int32? idBatch, System.Int32? newState)
		{
			 ChangeBatchState(null, start, pageLength , idBatch, newState);
		}
				
		/// <summary>
		///	This method wrap the 'ChangeBatchState' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newState"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public void ChangeBatchState(TransactionManager transactionManager, System.Int32? idBatch, System.Int32? newState)
		{
			 ChangeBatchState(transactionManager, 0, int.MaxValue , idBatch, newState);
		}
		
		/// <summary>
		///	This method wrap the 'ChangeBatchState' stored procedure. 
		/// </summary>
		/// <param name="idBatch"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newState"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		public abstract void ChangeBatchState(TransactionManager transactionManager, int start, int pageLength, System.Int32? idBatch, System.Int32? newState);
		
		#endregion

		
		#region GetUtenzeAll
		
		/// <summary>
		///	This method wrap the 'GetUtenzeAll' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetUtenzeAll(System.String cdPool, System.String cdMese, System.String cdTraderPrec)
		{
			return GetUtenzeAll(null, 0, int.MaxValue , cdPool, cdMese, cdTraderPrec);
		}
		
		/// <summary>
		///	This method wrap the 'GetUtenzeAll' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetUtenzeAll(int start, int pageLength, System.String cdPool, System.String cdMese, System.String cdTraderPrec)
		{
			return GetUtenzeAll(null, start, pageLength , cdPool, cdMese, cdTraderPrec);
		}
				
		/// <summary>
		///	This method wrap the 'GetUtenzeAll' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetUtenzeAll(TransactionManager transactionManager, System.String cdPool, System.String cdMese, System.String cdTraderPrec)
		{
			return GetUtenzeAll(transactionManager, 0, int.MaxValue , cdPool, cdMese, cdTraderPrec);
		}
		
		/// <summary>
		///	This method wrap the 'GetUtenzeAll' stored procedure. 
		/// </summary>
		/// <param name="cdPool"> A <c>System.String</c> instance.</param>
		/// <param name="cdMese"> A <c>System.String</c> instance.</param>
		/// <param name="cdTraderPrec"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetUtenzeAll(TransactionManager transactionManager, int start, int pageLength, System.String cdPool, System.String cdMese, System.String cdTraderPrec);
		
		#endregion

		
		#endregion

		#region Helper Functions
		
		/*
		///<summary>
		/// Fill an VList&lt;VBatchTraderPrecSt&gt; From a DataSet
		///</summary>
		/// <param name="dataSet">the DataSet</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList&lt;VBatchTraderPrecSt&gt;"/></returns>
		protected static VList&lt;VBatchTraderPrecSt&gt; Fill(DataSet dataSet, VList<VBatchTraderPrecSt> rows, int start, int pagelen)
		{
			if (dataSet.Tables.Count == 1)
			{
				return Fill(dataSet.Tables[0], rows, start, pagelen);
			}
			else
			{
				return new VList<VBatchTraderPrecSt>();
			}	
		}
		
		
		///<summary>
		/// Fill an VList&lt;VBatchTraderPrecSt&gt; From a DataTable
		///</summary>
		/// <param name="dataTable">the DataTable that hold the data.</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pagelen">number of row.</param>
		///<returns><see chref="VList<VBatchTraderPrecSt>"/></returns>
		protected static VList&lt;VBatchTraderPrecSt&gt; Fill(DataTable dataTable, VList<VBatchTraderPrecSt> rows, int start, int pagelen)
		{
			int recordnum = 0;
			
			System.Collections.IEnumerator dataRows =  dataTable.Rows.GetEnumerator();
			
			while (dataRows.MoveNext() && (pagelen != 0))
			{
				if(recordnum >= start)
				{
					DataRow row = (DataRow)dataRows.Current;
				
					VBatchTraderPrecSt c = new VBatchTraderPrecSt();
					c.IdTraderPrecStorico = (Convert.IsDBNull(row["Id_Trader_Prec_Storico"]))?(int)0:(System.Int32)row["Id_Trader_Prec_Storico"];
					c.Piva = (Convert.IsDBNull(row["piva"]))?string.Empty:(System.String)row["piva"];
					c.CdStoricoMensileRete = (Convert.IsDBNull(row["Cd_Storico_Mensile_Rete"]))?string.Empty:(System.String)row["Cd_Storico_Mensile_Rete"];
					c.IdTipologia = (Convert.IsDBNull(row["id_tipologia"]))?(int)0:(System.Int32?)row["id_tipologia"];
					c.CdPool = (Convert.IsDBNull(row["Cd_Pool"]))?string.Empty:(System.String)row["Cd_Pool"];
					c.DsSocieta = (Convert.IsDBNull(row["DsSocieta"]))?string.Empty:(System.String)row["DsSocieta"];
					c.CdSocieta = (Convert.IsDBNull(row["CdSocieta"]))?string.Empty:(System.String)row["CdSocieta"];
					c.DtIns = (Convert.IsDBNull(row["dt_ins"]))?DateTime.MinValue:(System.DateTime?)row["dt_ins"];
					c.CdShipper = (Convert.IsDBNull(row["CdShipper"]))?string.Empty:(System.String)row["CdShipper"];
					c.DsShipper = (Convert.IsDBNull(row["DsShipper"]))?string.Empty:(System.String)row["DsShipper"];
					c.IdBatch = (Convert.IsDBNull(row["Id_Batch"]))?(int)0:(System.Int32)row["Id_Batch"];
					c.Ltrader = (Convert.IsDBNull(row["LTrader"]))?string.Empty:(System.String)row["LTrader"];
					c.AcceptChanges();
					rows.Add(c);
					pagelen -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		*/	
						
		///<summary>
		/// Fill an <see cref="VList&lt;VBatchTraderPrecSt&gt;"/> From a DataReader.
		///</summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Start row</param>
		/// <param name="pageLength">number of row.</param>
		///<returns>a <see cref="VList&lt;VBatchTraderPrecSt&gt;"/></returns>
		protected VList<VBatchTraderPrecSt> Fill(IDataReader reader, VList<VBatchTraderPrecSt> rows, int start, int pageLength)
		{
			int recordnum = 0;
			while (reader.Read() && (pageLength != 0))
			{
				if(recordnum >= start)
				{
					VBatchTraderPrecSt entity = null;
					if (DataRepository.Provider.UseEntityFactory)
					{
						entity = EntityManager.CreateViewEntity<VBatchTraderPrecSt>("VBatchTraderPrecSt",  DataRepository.Provider.EntityCreationalFactoryType); 
					}
					else
					{
						entity = new VBatchTraderPrecSt();
					}
					
					entity.SuppressEntityEvents = true;

					entity.IdTraderPrecStorico = (System.Int32)reader[((int)VBatchTraderPrecStColumn.IdTraderPrecStorico)];
					//entity.IdTraderPrecStorico = (Convert.IsDBNull(reader["Id_Trader_Prec_Storico"]))?(int)0:(System.Int32)reader["Id_Trader_Prec_Storico"];
					entity.Piva = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.Piva)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.Piva)];
					//entity.Piva = (Convert.IsDBNull(reader["piva"]))?string.Empty:(System.String)reader["piva"];
					entity.CdStoricoMensileRete = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdStoricoMensileRete)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdStoricoMensileRete)];
					//entity.CdStoricoMensileRete = (Convert.IsDBNull(reader["Cd_Storico_Mensile_Rete"]))?string.Empty:(System.String)reader["Cd_Storico_Mensile_Rete"];
					entity.IdTipologia = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.IdTipologia)))?null:(System.Int32?)reader[((int)VBatchTraderPrecStColumn.IdTipologia)];
					//entity.IdTipologia = (Convert.IsDBNull(reader["id_tipologia"]))?(int)0:(System.Int32?)reader["id_tipologia"];
					entity.CdPool = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdPool)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdPool)];
					//entity.CdPool = (Convert.IsDBNull(reader["Cd_Pool"]))?string.Empty:(System.String)reader["Cd_Pool"];
					entity.DsSocieta = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.DsSocieta)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.DsSocieta)];
					//entity.DsSocieta = (Convert.IsDBNull(reader["DsSocieta"]))?string.Empty:(System.String)reader["DsSocieta"];
					entity.CdSocieta = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdSocieta)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdSocieta)];
					//entity.CdSocieta = (Convert.IsDBNull(reader["CdSocieta"]))?string.Empty:(System.String)reader["CdSocieta"];
					entity.DtIns = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.DtIns)))?null:(System.DateTime?)reader[((int)VBatchTraderPrecStColumn.DtIns)];
					//entity.DtIns = (Convert.IsDBNull(reader["dt_ins"]))?DateTime.MinValue:(System.DateTime?)reader["dt_ins"];
					entity.CdShipper = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdShipper)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdShipper)];
					//entity.CdShipper = (Convert.IsDBNull(reader["CdShipper"]))?string.Empty:(System.String)reader["CdShipper"];
					entity.DsShipper = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.DsShipper)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.DsShipper)];
					//entity.DsShipper = (Convert.IsDBNull(reader["DsShipper"]))?string.Empty:(System.String)reader["DsShipper"];
					entity.IdBatch = (System.Int32)reader[((int)VBatchTraderPrecStColumn.IdBatch)];
					//entity.IdBatch = (Convert.IsDBNull(reader["Id_Batch"]))?(int)0:(System.Int32)reader["Id_Batch"];
					entity.Ltrader = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.Ltrader)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.Ltrader)];
					//entity.Ltrader = (Convert.IsDBNull(reader["LTrader"]))?string.Empty:(System.String)reader["LTrader"];
					entity.AcceptChanges();
					entity.SuppressEntityEvents = false;
					
					rows.Add(entity);
					pageLength -= 1;
				}
				recordnum += 1;
			}
			return rows;
		}
		
		
		/// <summary>
		/// Refreshes the <see cref="VBatchTraderPrecSt"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="VBatchTraderPrecSt"/> object to refresh.</param>
		protected void RefreshEntity(IDataReader reader, VBatchTraderPrecSt entity)
		{
			reader.Read();
			entity.IdTraderPrecStorico = (System.Int32)reader[((int)VBatchTraderPrecStColumn.IdTraderPrecStorico)];
			//entity.IdTraderPrecStorico = (Convert.IsDBNull(reader["Id_Trader_Prec_Storico"]))?(int)0:(System.Int32)reader["Id_Trader_Prec_Storico"];
			entity.Piva = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.Piva)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.Piva)];
			//entity.Piva = (Convert.IsDBNull(reader["piva"]))?string.Empty:(System.String)reader["piva"];
			entity.CdStoricoMensileRete = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdStoricoMensileRete)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdStoricoMensileRete)];
			//entity.CdStoricoMensileRete = (Convert.IsDBNull(reader["Cd_Storico_Mensile_Rete"]))?string.Empty:(System.String)reader["Cd_Storico_Mensile_Rete"];
			entity.IdTipologia = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.IdTipologia)))?null:(System.Int32?)reader[((int)VBatchTraderPrecStColumn.IdTipologia)];
			//entity.IdTipologia = (Convert.IsDBNull(reader["id_tipologia"]))?(int)0:(System.Int32?)reader["id_tipologia"];
			entity.CdPool = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdPool)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdPool)];
			//entity.CdPool = (Convert.IsDBNull(reader["Cd_Pool"]))?string.Empty:(System.String)reader["Cd_Pool"];
			entity.DsSocieta = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.DsSocieta)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.DsSocieta)];
			//entity.DsSocieta = (Convert.IsDBNull(reader["DsSocieta"]))?string.Empty:(System.String)reader["DsSocieta"];
			entity.CdSocieta = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdSocieta)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdSocieta)];
			//entity.CdSocieta = (Convert.IsDBNull(reader["CdSocieta"]))?string.Empty:(System.String)reader["CdSocieta"];
			entity.DtIns = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.DtIns)))?null:(System.DateTime?)reader[((int)VBatchTraderPrecStColumn.DtIns)];
			//entity.DtIns = (Convert.IsDBNull(reader["dt_ins"]))?DateTime.MinValue:(System.DateTime?)reader["dt_ins"];
			entity.CdShipper = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.CdShipper)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.CdShipper)];
			//entity.CdShipper = (Convert.IsDBNull(reader["CdShipper"]))?string.Empty:(System.String)reader["CdShipper"];
			entity.DsShipper = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.DsShipper)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.DsShipper)];
			//entity.DsShipper = (Convert.IsDBNull(reader["DsShipper"]))?string.Empty:(System.String)reader["DsShipper"];
			entity.IdBatch = (System.Int32)reader[((int)VBatchTraderPrecStColumn.IdBatch)];
			//entity.IdBatch = (Convert.IsDBNull(reader["Id_Batch"]))?(int)0:(System.Int32)reader["Id_Batch"];
			entity.Ltrader = (reader.IsDBNull(((int)VBatchTraderPrecStColumn.Ltrader)))?null:(System.String)reader[((int)VBatchTraderPrecStColumn.Ltrader)];
			//entity.Ltrader = (Convert.IsDBNull(reader["LTrader"]))?string.Empty:(System.String)reader["LTrader"];
			reader.Close();
	
			entity.AcceptChanges();
		}
		
		/*
		/// <summary>
		/// Refreshes the <see cref="VBatchTraderPrecSt"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="VBatchTraderPrecSt"/> object.</param>
		protected static void RefreshEntity(DataSet dataSet, VBatchTraderPrecSt entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdTraderPrecStorico = (Convert.IsDBNull(dataRow["Id_Trader_Prec_Storico"]))?(int)0:(System.Int32)dataRow["Id_Trader_Prec_Storico"];
			entity.Piva = (Convert.IsDBNull(dataRow["piva"]))?string.Empty:(System.String)dataRow["piva"];
			entity.CdStoricoMensileRete = (Convert.IsDBNull(dataRow["Cd_Storico_Mensile_Rete"]))?string.Empty:(System.String)dataRow["Cd_Storico_Mensile_Rete"];
			entity.IdTipologia = (Convert.IsDBNull(dataRow["id_tipologia"]))?(int)0:(System.Int32?)dataRow["id_tipologia"];
			entity.CdPool = (Convert.IsDBNull(dataRow["Cd_Pool"]))?string.Empty:(System.String)dataRow["Cd_Pool"];
			entity.DsSocieta = (Convert.IsDBNull(dataRow["DsSocieta"]))?string.Empty:(System.String)dataRow["DsSocieta"];
			entity.CdSocieta = (Convert.IsDBNull(dataRow["CdSocieta"]))?string.Empty:(System.String)dataRow["CdSocieta"];
			entity.DtIns = (Convert.IsDBNull(dataRow["dt_ins"]))?DateTime.MinValue:(System.DateTime?)dataRow["dt_ins"];
			entity.CdShipper = (Convert.IsDBNull(dataRow["CdShipper"]))?string.Empty:(System.String)dataRow["CdShipper"];
			entity.DsShipper = (Convert.IsDBNull(dataRow["DsShipper"]))?string.Empty:(System.String)dataRow["DsShipper"];
			entity.IdBatch = (Convert.IsDBNull(dataRow["Id_Batch"]))?(int)0:(System.Int32)dataRow["Id_Batch"];
			entity.Ltrader = (Convert.IsDBNull(dataRow["LTrader"]))?string.Empty:(System.String)dataRow["LTrader"];
			entity.AcceptChanges();
		}
		*/
			
		#endregion Helper Functions
	}//end class

	#region VBatchTraderPrecStFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="VBatchTraderPrecSt"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class VBatchTraderPrecStFilterBuilder : SqlFilterBuilder<VBatchTraderPrecStColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStFilterBuilder class.
		/// </summary>
		public VBatchTraderPrecStFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public VBatchTraderPrecStFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public VBatchTraderPrecStFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion VBatchTraderPrecStFilterBuilder

	#region VBatchTraderPrecStParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="VBatchTraderPrecSt"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class VBatchTraderPrecStParameterBuilder : ParameterizedSqlFilterBuilder<VBatchTraderPrecStColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStParameterBuilder class.
		/// </summary>
		public VBatchTraderPrecStParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public VBatchTraderPrecStParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public VBatchTraderPrecStParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion VBatchTraderPrecStParameterBuilder
	
	#region VBatchTraderPrecStSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;EntityColumn&gt;"/> class
	/// that is used exclusively with a <see cref="VBatchTraderPrecSt"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class VBatchTraderPrecStSortBuilder : SqlSortBuilder<VBatchTraderPrecStColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VBatchTraderPrecStSqlSortBuilder class.
		/// </summary>
		public VBatchTraderPrecStSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion VBatchTraderPrecStSortBuilder

} // end namespace
